﻿using QGZX.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;


namespace QGZX.Logic
{
    public class HomeController:Controller
    {
        #region 首页页面方法 主要用于页面跳转
        /// <summary>
        /// 首页+ActionResult Index()
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {

            List<MODEL.qgzx_position> positionList = OperateContext.Current.BLLSession.Iqgzx_positionBLL.GetListBy(x => x.AuditStatus != null).ToList();
            ViewBag.positionList = positionList;
            List<MODEL.qgzx_article> articleList = OperateContext.Current.BLLSession.Iqgzx_articleBLL.GetListBy(x => x.IsAudit == 1).Take(5).ToList();
            ViewBag.articleList = articleList;
            return View();
        }

        public ActionResult cwy()
        {
            return View();
        }

        public ActionResult guidance()
        {
            return View();
        }

        public ActionResult head()
        {
            return View();
        }
        public ActionResult index_login()
        {
            return View();
        }
        public ActionResult introduce()
        {
            return View();
        }
        public ActionResult Link_bulletin()
        {
            return View();
        }
        public ActionResult Link_download()
        {
            return View();
        }
        public ActionResult Link_qgzx_LifeStyle()
        {
            return View();
        }
        public ActionResult Link_services()
        {
            return View();
        }

        public ActionResult new_list()
        {
            return View();
        }
        public ActionResult stuJobs()
        {
            return View();
        }

        public ActionResult trainpart()
        {
            return View();

        }

        public ActionResult zmjh()
        {
            return View();
        } 
        #endregion

        //---------------登录业务
        #region 用户 登陆业务 +  ActionResult Login()
        /// <summary>
        /// 用户 登陆业务
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ActionResult Login()
        {
            return View();
        }
        #endregion

        #region 用户 登陆业务 +  ActionResult Login(MODEL.ViewModel.LoginUser userInfo)
        /// <summary>
        /// 学生用户 登陆业务
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Login(MODEL.ViewModel.LoginUser userInfo)
        {

            if (OperateContext.Current.UserLogin(userInfo))
            {
                return OperateContext.Current.RedirectAjax("ok", "登陆成功", null, "/home/Index_login");
            }
            else
            {
                return OperateContext.Current.RedirectAjax("err", "登陆失败", null, "");
            }
        }
        #endregion

       //----------------注册业务
        #region 注册业务 分三步 ActionResult Register_1()
        /// <summary>
        /// 注册业务 分三步
        /// </summary>
        /// <returns></returns>
        public ActionResult Register_1()
        {
            return View();
        }

        public ActionResult Register_2(MODEL.ViewModel.Company company)
        {
            company.ToModel();
            return View(company);
        }

        public ActionResult Register_3(MODEL.ViewModel.Company company)
        {
            try
            {
                MODEL.qgzx_company c = company.ToModel();
                OperateContext.Current.BLLSession.Iqgzx_companyBLL.Add(c);
                return View();
            }
            catch
            {
                return OperateContext.Current.RedirectAjax("err", "操作失败，参数问题，请与管理员联系", null, "/home/index");
            }
        } 
        #endregion


        #region 详细文章信息+ ActionResult DetailArticle(int id)
        /// <summary>
        /// 详细文章信息+ ActionResult DetailArticle(int id)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult DetailArticle(int id)
        {
            var model = OperateContext.Current.BLLSession.Iqgzx_articleBLL.GetListBy(x => x.ArticleId == id).FirstOrDefault().ToViewModel();
            return View(model);
        }
        #endregion
    }
}

